//
//  KTHActBagroundV.m
//  KTLotteryTicket
//
//  Created by CoolKi on 16/3/5.
//  Copyright © 2016年 CoolKi. All rights reserved.
//

#import "KTHActBagroundV.h"

@implementation KTHActBagroundV

//展示一个KTHActBagroundV视图，并且传一个遵循(id<KTHActBagroundVDelegate>)的对象作为代理
+(void)showWithDelegate:(id<KTHActBagroundVDelegate>)obj{
    KTHActBagroundV * gbView = [[self alloc]init];
    gbView.frame = [UIScreen mainScreen].bounds;
    gbView.backgroundColor = [UIColor grayColor];
    gbView.alpha = 0.5;
    gbView.delegate = obj;
    //添加一个点击手势，用于隐藏自身以及其子控件
    UITapGestureRecognizer * tapGs = [[UITapGestureRecognizer alloc]initWithTarget:gbView action:@selector(tapTohidenSelfAndSubviews)];//注意：这里Target并不是self，如果写成self，既是把tap方法调用者写成self类，会报错！！
    [gbView addGestureRecognizer:tapGs];
    
    [[UIApplication sharedApplication].keyWindow addSubview:gbView];
    
}

//点击手势，触发代理方法
- (void)tapTohidenSelfAndSubviews{
    if ([self.delegate respondsToSelector:@selector(actBagroundV:)]) {
        [self.delegate actBagroundV:self];
    }
}



@end
